package DataSort;

public class Sort {
    public static void insertSorft(int[] array) {
        for (int i = 1; i < array.length; i++) {
            int j = i-1;
            int tmp = array[i];
            for (; j >= 0; j--) {
                if(array[j]>tmp) {
                    array[j+1] = array[j];
                }else {
                    break;
                }
            }
            array[j+1] = tmp;
        }
    }
    public static void shellSort(int[] array) {
        int gap = array.length;
        while(gap >= 1) {
            gap = gap/2;
            shell(array,gap);
        }
    }
    private static void shell(int[] array,int gap) {
        for (int i = gap; i < array.length; i++) {
            int j = i-gap;
            int tmp = array[i];
            for (; j >= 0; j-=gap) {
                if(array[j]>tmp) {
                    array[j+gap] = array[j];
                }else {
                    break;
                }
            }
            array[j+1] = tmp;
        }
    }
}
